package com.stx.test.object;

/**
 * packageName com.stx.test.object
 *
 * @author YangYi
 * @className StudentDemo
 * @date 2025/9/17
 * @description TODO
 */
public class StudentDemo {
    public static void main(String[] args) throws Exception{
        Student s1 = new Student(1001, "张三", 20);
        Student s2 = new Student(1001, "张三", 20); // 内容相同的不同对象
        Student s3 = new Student(1002, "李四", 21);
        Student s4 = s1; // 指向同一个对象

        System.out.println("s1.equals(s2): " + s1.equals(s2)); // true (id相同)
        System.out.println("s1.equals(s3): " + s1.equals(s3)); // false (id不同)
        System.out.println("s1.equals(s4): " + s1.equals(s4)); // true (是同一个对象)
        System.out.println("s1.equals(null): " + s1.equals(null)); // false
        System.out.println("s1.equals(字符串): " + s1.equals("字符串")); // false (类型不同)

        Student clone = (Student)s1.clone();
        System.out.println(s1);
        System.out.println(clone);
    }
}
